package cn.bdqn.utils;

import cn.bdqn.pojo.mySensitiveWord.SensitiveWord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

import static cn.bdqn.utils.RedisConstants.SENSITIVE_WORD_KEY;

@Component
public class SensitiveWordUtil {
    @Autowired
    private  RedisCache redisCache;

    public Boolean isSensitiveWord(String name){
        List<SensitiveWord> cacheList = redisCache.getCacheList(SENSITIVE_WORD_KEY);
        for (SensitiveWord sensitiveWord : cacheList) {
            if (sensitiveWord.getBadword().equals(name)) {
                return false;
            }
        }
        return true;
    }
}
